home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
textst.zip
/
TEXTST.PRG
< prev
Wrap
Text File
|
1993-04-12
|
2KB
|
78 lines
program Textst; {text file, sort then save to disk.}
uses crt, dos;
const
TextSize = 500; {Mod. #1}
LineLength = 80; {Mod. #1}
type
LineSize = string[LineLength];
String80 = string[80];
TextArrayType = array[1..TextSize] of LineSize;
var
TextArray : TextArrayType;
LineCount, Code, Position, Width : integer;
CharEntry : char;
FileSpec : String80;
{$I GetNumI.PSL}
{$I LoadTxt.PSL}
{$I SaveTxt.PSL}
{$I ShowDir.PSL}
{$I SortHT.PSL}
BEGIN
clrscr;
writeln('**** SortText Program ****');
writeln;
writeln('Maximum text lines that can be sorted = ', TextSize);
writeln('Maximum length of each text line = ', LineLength);
writeln;
writeln('For the sort key:');
writeln;
repeat
writeln('Enter the position number it starts in.');
GetNumI(Position, CharEntry, Code);
if (Position < 1) or (Position > 255) then
Code := -3;
if Code <> 0 then
writeln(#7, '** Illegal entry **')
until
Code = 0;
writeln;
repeat
writeln('Enter the sort key length.');
GetNumI(Width, CharEntry, Code);
if (Width < 1) or (Width > 255) then
Code := -4;
if Code <> 0 then
writeln(#7, '** Illegal entry **')
until
Code = 0;
writeln;
writeln;
FileSpec := '*.*'; {Mod. #2}
writeln('Files in current active directory are'); {Mod. #2}
ShowDir(FileSpec, 0);
writeln;
LineCount := 0;
LoadTxt(TextArray, LineCount, Code);
if Code <> 0 then
begin
writeln('** Program aborted **');
halt
end;
SortHT(TextArray, LineCount, Position, Width);
writeln;
writeln(LineCount, ' lines of text sorted');
writeln;
SaveTxt(TextArray, LineCount, Code);
writeln;
if Code <> 0 then
writeln('Unsuccessful file save.')
else
writeln('Sorted file successfully saved');
writeln
END.